{% extends "base.html" %}

{% block title %}编辑错题 #{{ mistake.id }}{% endblock %}

{% block content %}
<div class="row">
    <div class="col-md-8 mx-auto">
        <div class="d-flex justify-content-between align-items-center mb-4">
            <h1><i class="bi bi-pencil-square"></i> 编辑错题 #{{ mistake.id }}</h1>
            <a href="{{ url_for('view_mistake', mistake_id=mistake.id) }}" class="btn btn-secondary">
                <i class="bi bi-arrow-left"></i> 返回详情
            </a>
        </div>
        
        <div class="card">
            <div class="card-body">
                <form method="POST">
                    <div class="mb-3">
                        <label for="exam_type" class="form-label">考试类型</label>
                        <input type="text" list="exam-types" class="form-control" id="exam_type" name="exam_type" 
                               placeholder="例如: 系统集成项目管理工程师, 软件设计师" value="{{ mistake.exam_type or '' }}">
                        <datalist id="exam-types">
                            {% for exam_type in exam_types %}
                            <option value="{{ exam_type }}">{{ exam_type }}</option>
                            {% endfor %}
                        </datalist>
                        <div class="form-text">输入或选择考试类型</div>
                    </div>
                    
                    <div class="mb-3">
                        <label for="question" class="form-label">题目</label>
                        <textarea class="form-control" id="question" name="question" rows="4" required placeholder="请输入题目内容...">{{ mistake.question }}</textarea>
                    </div>
                    
                    <div class="row">
                        <div class="col-md-6">
                            <div class="mb-3">
                                <label for="user_answer" class="form-label">你的答案</label>
                                <input type="text" class="form-control" id="user_answer" name="user_answer" required placeholder="请输入你的答案" value="{{ mistake.user_answer }}">
                            </div>
                        </div>
                        <div class="col-md-6">
                            <div class="mb-3">
                                <label for="correct_answer" class="form-label">正确答案</label>
                                <input type="text" class="form-control" id="correct_answer" name="correct_answer" required placeholder="请输入正确答案" value="{{ mistake.correct_answer }}">
                            </div>
                        </div>
                    </div>
                    
                    <div class="mb-3">
                        <label for="knowledge_points" class="form-label">知识点（用逗号分隔）</label>
                        <input type="text" class="form-control" id="knowledge_points" name="knowledge_points" 
                               placeholder="例如: 网络协议, 数据库设计, 软件工程" value="{{ mistake.knowledge_points or '' }}">
                        <div class="form-text">可以输入多个知识点，用逗号分隔</div>
                    </div>
                    
                    <div class="mb-3">
                        <label for="explanation" class="form-label">解析</label>
                        <textarea class="form-control" id="explanation" name="explanation" rows="4" placeholder="解释为什么正确答案是对的，以及你的答案错在哪里...">{{ mistake.explanation or '' }}</textarea>
                    </div>
                    
                    <div class="d-grid gap-2 d-md-flex justify-content-md-end">
                        <button type="submit" class="btn btn-primary">
                            <i class="bi bi-save"></i> 保存修改
                        </button>
                        <a href="{{ url_for('view_mistake', mistake_id=mistake.id) }}" class="btn btn-secondary">取消</a>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
{% endblock %}